from flask import Flask,render_template,request,flash

app = Flask(__name__)
app.secret_key = 'asd54as35d4as54'

@app.route('/index',methods=['GET','POST'])

def register():
    if request.method == 'POST':
        username = request.form.get('username')
        password = request.form.get('password')
        password2 = request.form.get('password2')
        if not all([username,password,password2]):
            flash('请填入完整信息',category='message')
        elif (len(username) < 3 and len(username) > 0) or len(username) > 15:
            flash('用户名长度应大于3小于15',category='info')
        elif password2 != password:
            flash('密码不一致',category='error')
        else:
            return '注册成功'

    return render_template('register.html')

if __name__ == '__main__':
    app.run()
